//
//  UserNameFroDetail.m
//  PetApp
//
//  Created by dllo on 16/3/14.
//  Copyright © 2016年 apple. All rights reserved.
//

#import "UserNameFroDetail.h"

@interface UserNameFroDetail ()

@property (nonatomic, retain) UITextField *textField;

@end

@implementation UserNameFroDetail

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view.
    self.view.backgroundColor = [UIColor colorWithRed:0.9462 green:0.9416 blue:0.9508 alpha:1.0];
    UIButton *rightButton = [UIButton buttonWithType:UIButtonTypeCustom];
    [rightButton setTitle:@"保存" forState:UIControlStateNormal];
    [rightButton setTitleColor:[UIColor brownColor] forState:UIControlStateNormal];
    rightButton.frame = CGRectMake(0, 0, 50, 50);
    [rightButton addTarget:self action:@selector(handleAction) forControlEvents:UIControlEventTouchUpInside];
    
    
    self.navigationItem.rightBarButtonItem = [[UIBarButtonItem alloc] initWithCustomView:rightButton];
    
    [self createSubViews];
}

- (void)createSubViews {
    UIView *backView = [[UIView alloc] initWithFrame:CGRectMake(0, 30, self.view.frame.size.width, 30)];
    [self.view addSubview:backView];
    [backView release];
    backView.backgroundColor = [UIColor whiteColor];
    
    self.textField = [[UITextField alloc] initWithFrame:CGRectMake(20, 0, self.view.frame.size.width - 20, 30)];
    [backView addSubview:_textField];
    [_textField release];
    self.textField.backgroundColor = [UIColor whiteColor];
    self.textField.text = self.textContent;
    
    UILabel *labelOfTip = [[UILabel alloc] initWithFrame:CGRectMake(10, 90, self.view.frame.size.width, 60)];
    [self.view addSubview:labelOfTip];
    [labelOfTip release];
    labelOfTip.text = @"格式: 汉字 英文 数字 下划线组成, 2-20位\n提示:昵称只能修改一次!";
    labelOfTip.textColor = [UIColor grayColor];
    labelOfTip.font = [UIFont systemFontOfSize:15];
    labelOfTip.numberOfLines = 0;
    
    
}

- (void)handleAction {
    self.block(self.textField.text);
    [self.navigationController popViewControllerAnimated:YES];
    
}
- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
